Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(typescript): Move to BuilderProgram API #217

Merged
merged 23 commits into from
Feb 28, 2020
Merged

Conversation

NotWoods
Copy link
Member

@NotWoods NotWoods commented Feb 20, 2020

Rollup Plugin Name: typescript

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers: #216, #205, #204, #70, #61

Description

This is another refactor to move from LanguageService (meant for IDEs) to BuilderProgram (meant for partial recomplation). This makes some big changes to the plugin to better align with what Typescript does: rather than Rollup giving us files to transform and the plugin transforming them on the fly, Typescript detects all source files and does a entire project transpilation at the very start. This is similar to Jake Archibald's simple-ts plugin, except the compilation is done in-memory rather than with a temp directory. BuilderProgram is also used by Webpack's ts-loader. Since the behavior is better aligned with Typescript, this fixes some odd inconsistencies in the typechecking like #204 and #211.

We now support the declaration and declarationMap options with this change! When generating declaration files, the outDir must be set and be pointed to Rollup's output dir (or some subfolder). This allows us to use Rollup's asset emit API, and other plugins can then intercept these assets to potentially bundle the declaration files later. We currently emit each file separately, similar to rollup-plugin-typescript2.

This also adds experimental support for incremental builds, and paves the way for project references/build mode too.

Breaking changes

All files discovered by Typescript will be compiled. The include/exclude filter can be used to filter out the files that Typescript finds. By default, all files in a directory with the tsconfig.json will be included, so most projects should not need additional changes. Our tests have been updated to have tsconfig.json files in each fixture directory, since we don't want all fixtures to be compiled for each test.

tslib can no longer be overriden by passing in source code directly. Now, it must be a path to a file. This better aligns with other plugins and is probably the expected behavior. Users can migrate by placing their custom tslib source code inside a file in their project, then including a path to it inside the plugin options.

The declaration, declarationMap, incremental, and tsBuildInfoFile options are no longer ignored. If these options are set, then a Rollput output dir must be used and Typescript's outDir/declarationDir must be located inside of it.Compilationn will fail if these directories are not set to be within dir.

We also fail compilation if the deprecated out option is used, or if the incompatible outFile is used.

@paulrostorp
Copy link

Is this ready for review ?

@NotWoods
Copy link
Member Author

Yes

@NotWoods NotWoods merged commit 262cf3d into master Feb 28, 2020
@NotWoods NotWoods deleted the ts-watcher-api branch February 28, 2020 17:38
simonihmig added a commit to simonihmig/ecsy-babylon that referenced this pull request Mar 4, 2020
the errors itself are not present when working directly with TS (e.g. `yarn lint:ts`). Seems to be a bug in the rollup plugin, which is hopefully fixed with the next release (rollup/plugins#217)
@danimoh danimoh mentioned this pull request Mar 9, 2020
LarsDenBakker pushed a commit to LarsDenBakker/plugins that referenced this pull request Sep 12, 2020
* Move to BuilderProgram API

* Update tests for new API

* Use include/exclude for files

* Clean up refactored code

* Change tslib to be a path instead of source

* Update overriding test

* Work on supporting project references

* Working declaration files

* Stop watching after build is done

* Add warnings for sourceMap flag

* Add incremental build support

* Add rebuild test

* Separate module resolution

* Work on project reference support

* Fix incremental test

* Fix path normalization

* Cleanup

* Update override options

* Skip project reference test

* Try skipping incremental build

* Try no cache

* Try serial

* Posix paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants